<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Product extends CI_Controller {
    
    /**
     * Index action 
     * @author tien.nguyen
     */
	public function index($page = 1){	
        //instance model
        $this->load->model('Products', '', true);
        
        $page = empty($page) ? 0 : $page;
        //load data by model 
        $data['Products'] = $this->Products->getListProduct($page);
		$this->load->view('product/index', $data);
	}
    
    /**
     * Index action 
     * @author tien.nguyen
     */
	public function productCate($cateId, $page = 1){	
        //instance model
        $this->load->model('Products', '', true);
        
        $page = empty($page) ? 0 : $page;
        //load data by model 
        $data['Products'] = $this->Products->getListProductCate($cateId, $page);
		$this->load->view('product/index', $data);
	}
    
    /**
     * get detail
     * @author tien.nguyen
     */
    public function detail($productId){
        //instance model
        $this->load->model('Products', '', true);
        
        $data['Product'] = $this->Products->getProduct($productId);
		$this->load->view('product/detail', $data);
    }
}